package net.pulseproject.router.config.instantiator.builder;

import java.util.Collection;

import net.pulseproject.commons.midi.Receivable;
import net.pulseproject.router.config.instantiator.builder.validator.FieldValidator;
import net.pulseproject.router.config.instantiator.builder.validator.SkeletonFieldValidator;
import net.pulseproject.router.modules.BiDirectionalModule;

public abstract class BiDirectionalModuleBuilder<T extends BiDirectionalModule> extends Builder<T> {
	
	private Collection<Receivable> outgoingModules;
	

	private final FieldValidator validator = new SkeletonFieldValidator() {
		@SuppressWarnings("synthetic-access")
		@Override
		protected void validateFields() {
			if(BiDirectionalModuleBuilder.this.outgoingModules == null) {
				throw new RuntimeException("outgoingModules not yet set");
			}
		}
	};
	
	public BiDirectionalModuleBuilder() {
		this.addValidator(this.validator);
	}
	
	public final void setOutgoingModules(final Collection<Receivable> outgoingModules) {
		this.outgoingModules = outgoingModules;
	}
	
	protected final Collection<Receivable> getOutgoingModules() {
		return this.outgoingModules;
	}
}
